{extend name="light-year/layout/master/detail" /}

{block name="title"}省市区管理{/block}
{block name="page-title"}省市区{/block}

{block name="content"}
    <input name="region_id" class="form-control" type="hidden" value="{if $detail}{$detail->region_id}{/if}" />
    <div class="form-group">
        <label><span class="text-danger">*</span> 父级栏目：</label>
        <div class="form-controls">
            <?php $parent_id = input('parent_id', 0);?>
            <select name="parent_id" class="form-control" required>
                <option value="0">--默认顶级--</option>
                {if !empty($regions)}
                    {foreach $regions as $region}
                        <option value="{$region['region_id']}"
                                {if $detail}
                                    {$region['region_id'] == $detail->parent_id ? 'selected' : ''}
                                {else /}
                                    {$region['region_id'] == $parent_id ? 'selected' : ''}
                                {/if}
                            > {$region['name']} </option>
                        {if !empty($region['_child'])}
                            {foreach $region['_child'] as $child}
                                <option value="{$child['region_id']}"
                                        {if $detail}
                                            {$child['region_id'] == $detail->parent_id ? 'selected' : ''}
                                        {else /}
                                            {$child['region_id'] == $parent_id ? 'selected' : ''}
                                        {/if}
                                    >├───{$child['name']} </option>
                            {/foreach}
                        {/if}
                    {/foreach}
                {/if}
            </select>
        </div>
    </div>
    <div class="form-group">
        <label><span class="text-danger">*</span> 名称：</label>
        <input type="text" class="form-control" name="name" value="{if $detail}{$detail->name}{/if}" placeholder="输入名称" required="" />
        <small class="help-block">
            <i class="mdi mdi-information"></i>
            唯一标识
        </small>
    </div>
    <div class="form-group">
        <button type="submit" class="btn btn-primary ajax-post" target-form="add-form">确 定</button>
        <button type="button" class="btn btn-default" onclick="javascript:history.back(-1);return false;">返 回</button>
    </div>
{/block}